The x pixel of a sprite asset’s own origin, measured from its top-left — the point default drawing, draw_sprite/draw_sprite_ext/draw_self, and instance_create all treat as “where this sprite is”. Unset (no origin authored in the Sprites tab) answers the sprite’s own center, exactly where it drew before this existed.
Sega Genesis: not built yet
On other consoles this differs: see Side by side and How the consoles differ.
sprite_origin_x(spr) -> int| Name | Type |
|---|---|
spr | sprite |
int
The x pixel of a sprite asset's own origin, measured from its top-left - the point default drawing, draw_sprite/draw_sprite_scaled/draw_self, and instance_create all treat as "where this sprite is". An origin is authored per sprite in the Sprites tab (click the pixel it should be); a sprite nobody has ever given one answers its own center here (sprite_width(spr) / 2), which is also exactly where it already drew before origins existed - so an unauthored sprite's placement never changes.
Most of the time you never need this directly: place something with x/y, instance_create, or draw_sprite, and the origin is already where it lands. Reach for sprite_origin_x/sprite_origin_y when you need the raw pixel itself - for example to find where a sprite's art actually extends TO, regardless of where its origin was authored.
right_edge_x = x + (sprite_width(spr_doc_hero) - sprite_origin_x(spr_doc_hero));The x position of this sprite's own rightmost drawn pixel in the room, whatever its origin is set to - useful for docking something (a health bar, a held item) against the art's real edge instead of against wherever the origin happens to sit.
A runtime read of a small per-project table (typically empty, or a handful of rows), not a compile-time constant like sprite_width. Still cheap: a short scan by pointer identity, no branches worth worrying about on an ARM7TDMI.